package com.kupal.ahk.event;

import com.kupal.ahk.dict.Key;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;


/**
 * Represent operations with keyboard
 * @author Krauchenia Sergey
 *         Date: 13.10.2010
 *         Time: 15:37:57
 */
public class Keyboard extends Event {

    public static void send(String text) {
        throw new NotImplementedException();
    }

    /**
     * Pressing and releasing list of keys (macros)
     * @param macros list of keys
     */
    public static void send(Key...macros) {
        send(0, macros);
    }

    /**
     * Pressing and releasing list of keys (macros)
     * with specified delay in milliseconds
     * @param ms delay time between key pressing in milliseconds
     * @param macros list of keys
     */
    public static void send(int ms, Key...macros) {
        press(ms, macros);
        release(ms, macros);
    }

    /**
     * Presses a given list of keys
     * @param macros list of keys
     */
    public static void press(Key...macros) {
        press(0, macros);
    }

    /**
     * Presses a given list of keys with
     * specified delay in milliseconds
     * @param ms delay time between key pressing in milliseconds
     * @param macros list of keys
     */
    public static void press(int ms, Key...macros) {
        for (Key key : macros) {
            ROBOT.keyPress(key.id);
            ROBOT.delay(ms);
        }
    }

    /**
     * Releases a given list of keys
     * @param macros list of keys
     */
    public static void release(Key...macros) {
        release(0, macros);
    }

    /**
     * Releases a given list of keys with
     * specified delay in milliseconds
     * @param ms delay time between key releasing in milliseconds
     * @param macros list of keys
     */
    public static void release(int ms, Key...macros) {
        for (Key key : macros) {
            ROBOT.keyRelease(key.id);
            ROBOT.delay(ms);
        }
    }
}
